var hideMore=document.getElementsByClassName("hideMore")[0];
var hideMusic=document.getElementsByClassName("hideMusic")[0];
var img1 =document.getElementById("img1");
function showMore(){
    hideMore.style.display="block";
    hideMore.style.opacity="1";
    hideMore.style.transition=".5s";
}
function offMore(){
    hideMore.style.display="none";
    hideMore.style.opacity="0";
    hideMore.style.transition="0";
}
//修改个人信息
var navFirstBtn=document.getElementsByClassName("navFontBtn")[0];
var alter=document.getElementsByClassName('alter');
var hideperson=document.getElementsByClassName("hideperson")[0];
var changeYesBtn=document.getElementsByClassName("changeYesBtn")[0];
var changeBtn=document.getElementsByClassName("changeBtn")[0];
var changeNoBtn=document.getElementsByClassName("changeNoBtn")[0];
var personCenter=document.getElementsByClassName("personCenter")[0];
var navItem1=document.getElementsByClassName("navItem")[2];
var personButton=document.getElementsByClassName('personButton')[0];
navFirstBtn.onclick=function(){
    hideperson.style.display="block";
    setTimeout(function(){
        personCenter.style.opacity="1";
    },1)
    // 点击修改按钮
    changeBtn.onclick=function(){
        // personCenter的样式修改
        personCenter.style.boxShadow='0 0 15px #707070';
        personCenter.style.transform='translate('+ -50 +'%,'+ -190 +'px)';
        changeYesBtn.style.display='block';
        changeBtn.style.display='none';
        changeNoBtn.style.display='block';
    }
}
console.log(User.userName);
$('.personButton').on('click','.changeYesBtn',function(){
    $.ajax({
        url:'http://localhost:8080/future/user/updateuserUser',
        type:'GET',
        data:{
            userName:alter[0].value,
            userBirth:alter[2].value,
            userId:alter[3].value,
            userEmail:alter[4].value,
            userGen:alter[5].value,
        },
        success:function(data){
            alter[0].innerHTML=User.userName;
            alter[2].innerHTML=User.userBirth;
            alter[3].innerHTML=User.userEmail;
            alter[4].innerHTML=User.userGen;
            console.log(data);
            window.Location.href='loginpage';
            changeYesBtn.style.display='none';
            changeNoBtn.style.display='none';
            changeBtn.style.display='block';
            personCenter.style.boxShadow='none';
            personCenter.style.transform='translate('+ -50 +'%,'+ -180 +'px)';
        },
        error:function(){
            console.log('错误');
        }
    })
})
var closeChange=document.getElementsByClassName('closeChange')[0];
closeChange.onclick=closeForm;
changeNoBtn.onclick=closeForm;
function closeForm(){
    // changeYesBtn.style.display='none';
    // changeNoBtn.style.display='none';
    // changeBtn.style.display='block';
    //
    // personCenter.style.boxShadow='none';
    // personCenter.style.transform='translate('+ -50 +'%,'+ -180 +'px)';
    setTimeout(function(){
        hideperson.style.display="none";

    },270)
    personCenter.style.transform="translate("+ -50+"%"+ -300 +"px)";
    personCenter.style.opacity="0";
}
// 修改个人信息 end

//取消收藏的弹框
// 弹框的内容

var hideCollect = document.getElementsByClassName('hideCollect')[0];
var hideCollectForm = document.getElementsByClassName('hideCollectForm')[0];

var collectNoBtn = document.getElementsByClassName('collectNoBtn')[0];
var closeCollect = document.getElementsByClassName('closeCollect')[0];
collectNoBtn.onclick = closeCollectForm;
closeCollect.onclick = closeCollectForm;
var hhh=document.getElementsByClassName('hhh');
var delHide=document.getElementsByClassName('delHide');
// delHide.onclick = showCollectForm;
// console.log(delHide.length);
// console.log(hhh.children[2].innerHTML);

console.log("mcname");
console.log(Name);
for(var i=0;i<delHide.length;i++){
    var Name=hhh[i].children[2].innerHTML;
    delHide[i].onclick = function(){
        hideCollect.style.display = 'block';
        setTimeout(function(){
            hideCollectForm.style.opacity = '1';
            hideCollectForm.style.transform = "translate(" + -50 + "%)";
        },300)
    }
}

// function showCollectForm(){
//     hideCollect.style.display = 'block';
//     setTimeout(function(){
//         hideCollectForm.style.opacity = '1';
//         hideCollectForm.style.transform = "translate(" + -50 + "%)";
//     },300)
//
// }

var collectYesBtn=document.getElementsByClassName('collectYesBtn')[0];
collectYesBtn.onclick=function(){
    $.ajax({
        url:"http://localhost:8080/future/music/addMusictoLovelist",
        method:"post",
        data:{
            mcName:Name
        },
        success:function(data) {
            console.log(data);
            console.log(data.statusCode)
            console.log(data.info)
            if(data.statusCode==0){

            }
            window.location.reload();
            hideCollect.style.display = 'none';
            hideCollectForm.style.opacity = '0';
            hideCollectForm.style.transform = "translate(" + -50 + "%)";
        },
        error:function(err){
            console.log('错误');
        }


    })
}
//关闭收藏的表单
function closeCollectForm(){
    setTimeout(function(){
        hideCollect.style.display = 'none';
        hideCollectForm.style.opacity = '0';
        hideCollectForm.style.transform = "translate(" + -50 + "%)";
    },270)
}
//取消收藏的弹框 end


//点击我的下载的弹框
// 弹框的内容
var hideLoad = document.getElementsByClassName('hideLoad')[0];
var hideLoadForm = document.getElementsByClassName('hideLoadForm')[0];
var delLoad=document.getElementsByClassName('delLoad')[0];
var loadNoBtn = document.getElementsByClassName('loadNoBtn')[0];
var closeLoad = document.getElementsByClassName('closeLoad')[0];
var loadYesBtn=document.getElementsByClassName('loadYesBtn')[0];
loadYesBtn.onclick = closeLoadForm;
loadNoBtn.onclick = closeLoadForm;
closeLoad.onclick = closeLoadForm;
delLoad.onclick = showLoadForm;
function showLoadForm(){
    hideLoad.style.display = 'block';
    setTimeout(function(){
        hideLoadForm.style.opacity = '1';
        hideLoadForm.style.transform = "translate(" + -50 + "%)";
    },1)
}

//关闭下载的表单
function closeLoadForm(){
    setTimeout(function(){
        hideLoad.style.display = 'none';
        hideLoadForm.style.opacity = '0';
        hideLoadForm.style.transform = "translate(" + -50 + "%)";
    },270)
}
//取消下载的弹框 end

// 列表的颜色变化
var inquireTbody = document.getElementsByClassName('inquireTbody')[0];
console.log(inquireTbody.children[0]);
for(var i = 0;i < inquireTbody.children.length;i++){
    if(i%2==0){
        inquireTbody.children[i].style.backgroundColor="white";
    }else{
        inquireTbody.children[i].style.backgroundColor="rgba(0,0,0,.02)";
    }
}
var inquireTbody = document.getElementsByClassName('inquireTbody')[1];
console.log(inquireTbody.children[0]);
for(var i = 0;i < inquireTbody.children.length;i++){
    if(i%2==0){
        inquireTbody.children[i].style.backgroundColor="white";
    }else{
        inquireTbody.children[i].style.backgroundColor="rgba(0,0,0,.02)";
    }
}

//列表颜色的变化  end
//我喜欢(收藏)和我的歌单之间变换页面
// 推荐歌单的变换页面
var navItem=document.getElementsByClassName('navItem');
var showSongs=document.getElementsByClassName('showSongs');

var noActive=function(){
    for(let i=0;i<showSongs.length;i++){
        showSongs[i].className='showSongs'
    }
    for(let i=0;i<navItem.length;i++){
        navItem[i].className='navItem';
    }
}
var gotoIndex=function(e){
    console.log(e)
    noActive();
    showSongs[e].className='showSongs active';
    navItem[e].className='navItem active';
}
for(let i=0;i<navItem.length;i++){
    navItem[i].addEventListener('click',function(){
        console.log(i);
        gotoIndex(i);
    })
}
//登录成功以及出现退出登录
var name=document.getElementsByClassName('userName')[0];
var login=document.getElementsByClassName('login')[0];
var persons=document.getElementsByClassName('persons')[0];
var out=document.getElementsByClassName('out')[0];
var hideLogOut = document.getElementsByClassName('hideLogOut')[0];
var hideLogOutContent = document.getElementsByClassName('hideLogOutContent')[0];
var logOutNoBtn=document.getElementsByClassName('logOutNoBtn')[0];
var logOutYesBtn=document.getElementsByClassName('logOutYesBtn')[0];
// if(localStorage.getItem('userHao')!=null || localStorage.getItem('sign')==1){
//     login.style.display='none';
//     persons.style.display='block';
// }
// console.log(localStorage.getItem('userHao'))
// console.log(localStorage.getItem('password'))
out.onclick=function(){
    setTimeout(function(){
        hideLogOut.style.display = 'block';
        hideLogOutContent.style.opacity = '1';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + 400 + "px)";
    },1)
    logOutNoBtn.onclick = function(){
        hideLogOutContent.style.opacity = '0';
        hideLogOutContent.style.transform = "translate(" + -50 + "%," + -400 + "px)";
        hideLogOut.style.display = 'none';
    }
//点击确认会退出登录
    logOutYesBtn.onclick = function(){
        localStorage.removeItem('userHao');
        localStorage.removeItem('password');
        localStorage.removeItem('sign');
        window.location.href="http://localhost:8080/future/out";
    }


}
